<template>
  <common-table
    ref="table"
    :fetch="getDataAsync"
    :fetch-params="apiParams"
    :columns="columns"
    :show-toolbar="false"
    @vue:mounted="() => $refs.table.load()"
    style="width: 100%; height: 100%"
  >
    <template #action="{ scope }">
      <a-button type="link" @click="details(scope)">查看异常情况</a-button>
    </template>
  </common-table>
</template>

<script>
import CommonTable from '@gis/lib/components/vex-table/index.vue';
import { dialog } from '@gis/lib/components/antd-dialog';

export default {
  name: 'interview-info',
  components: { CommonTable },
  props: {
    data: { type: Object, default: () => ({}) },
  },
  data() {
    return {
      columns: [
        {
          title: '走访人',
          dataIndex: 'people_name',
        },
        {
          title: '走访日期',
          dataIndex: 'time',
        },
        {
          title: '是否签收',
          dataIndex: 'is_receive',
          customRender: (v) => (v ? '是' : '否'),
        },
        {
          title: '异常数量',
          dataIndex: 'abnormal_num',
        },
        {
          title: '备注',
          dataIndex: 'remark',
          ellipsis: true,
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
    };
  },
  computed: {
    apiParams() {
      return { people_id: this.data.people_id };
    },
  },
  methods: {
    async getDataAsync(params) {
      const res = await this.$axios.get('/xw-microservice/xw-actual-data/v3/people/special/visit/pagination', {
        params,
      });
      const data = res.data || {};
      return { data: data.list, total: data.count };
    },
    async add() {},
    details(data) {
      dialog({
        content: () => import('./components/interview-info-details.vue'),
        contentProps: { data },
        dialogProps: {
          title: '查看详情',
          footer: null,
        },
      });
    },
  },
};
</script>

<style scoped lang="less">
.interview-info {
  width: 100%;
  height: 100%;
  .details-btn {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #62b8b1;
    cursor: pointer;
  }
}
</style>
